<template>
  <div>
    <el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible">
      <el-form ref="dataForm" :model="temp" label-position="left" label-width="70px" style='width: 400px; margin-left:50px;'>
        
        <el-form-item :label="'名称'">
          <el-input v-model="temp.name"></el-input>
        </el-form-item>
        <el-form-item :label="'描述'">
          <el-input type="textarea" :autosize="{ minRows: 2, maxRows: 4}" placeholder="Please input" v-model="temp.description">
          </el-input>
        </el-form-item>
        <el-form-item :label="'联系电话'">
          <el-input v-model="temp.phone"></el-input>
        </el-form-item>

      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible = false">取消</el-button>
        <el-button v-if="dialogStatus=='create'" type="primary" @click="submitData">确定</el-button>
        <!-- <el-button v-else type="primary" @click="updateData">{{$t('table.confirm')}}</el-button> -->
      </div>
    </el-dialog>
  </div>
</template>
<script type="text/javascript">
import { createCombo } from '@/api/combo'
export default {
   props: {
    dialogStatus: {
      type: String,
      default () {
        return 'create'
      }
    }
  },
  data() {
    return {
      dialogFormVisible: false,
      textMap: {
        update: '编辑',
        create: '新增'
      },
      temp: {
        id: undefined,
        name: '',
        description: '',
        phone: ''
      }
    }
  },
  methods: {
    submitData() {
      if (this.dialogStatus === 'create') {
        console.log('create')
        // createCombo
        createCombo(this.temp).then(response => {
          console.log('response: ', response)
          this.dialogFormVisible = false
        })
      }
      if (this.dialogStatus === 'edit') {
        console.log('create')
      }
    }
  }
}
</script>